package com.hs.controller;

import com.github.pagehelper.PageInfo;
import com.hs.entity.HomeCarousel;
import com.hs.service.HomeCarouselService;
import com.hs.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("homecarousel")
public class HomeCarouselController {
    @Autowired
    private HomeCarouselService homeCarouselService;
    @GetMapping("{id}")
    public R getHomeCarousel(@PathVariable("id") int id) {
        HomeCarousel hh = homeCarouselService.selectById(id);
        return R.ok(hh);
    }
    @GetMapping("page")
    public R getHomeCarouselByPage(HomeCarousel homeCarousel,
                                   @RequestParam(required = false,defaultValue = "1") int pageNum,
                                   @RequestParam(required = false,defaultValue = "2") int pageSize) {
        PageInfo<HomeCarousel> homeCarouseByPage = homeCarouselService.getHomeCarouseByPage(homeCarousel, pageNum, pageSize);
        return R.ok(homeCarouseByPage);
    }
}
